﻿<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" 
                xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
                xmlns:msxsl="urn:schemas-microsoft-com:xslt" 
                exclude-result-prefixes="msxsl">
  <xsl:output method="html" indent="yes"/>
  <xsl:strip-space elements="*"/>
  <xsl:template match="/">
    <html>
      <head>
        <title>Search Results</title>
        <style type="text/css">
          body
          {
          font-family:"Helvetica,Verdana,Arial";
          font-size:small;
          font-size:12px;
          }

          th
          {
          background:#336699;
          color:White;
          border:0px;
          font-size:12px;
          }
          td
          {
          font-size:12px;
          }
          #MainTable
          {
          padding:0;
          margin:0;
          border-width:0px;
          vertical-align:top;
          }
          .TitleCell
          {
          /*font-weight:bold;*/
          font-style:italic;
          }
          .AbstractCell
          {
          font-size:10px;
          }
          .UrlCell
          {
          font-size:10px;
          }
          .ResultsInnerTable
          {
          }
          .SearchTextCell
          {
          vertical-align:top
          }
          .Row0
          {
          background:#EEEEEE;
          }
          .Row1
          {
          background:white;
          }
        </style>
      </head>
      <body>
        <table>
          <tr>
            <th>Text</th>
            <th>Results</th>
          </tr>
          <xsl:for-each select="/ArrayOfPairedSearchResults/PairedSearchResults">
            <xsl:element name="tr">
              <xsl:attribute name="class">
                <xsl:if test="position()  mod 2 = 1">Row1</xsl:if>
                <xsl:if test="position()  mod 2 = 0">Row0</xsl:if>
              </xsl:attribute>
              <td class="SearchTextCell">
                <xsl:value-of select="SearchText"/>
                <br/>
                (<xsl:value-of select="count(Results/SearchResult)"/>) matches
              </td>
              <td>
                <table>
                  <xsl:for-each select="Results/SearchResult">
                    <tr>
                      <td class="TitleCell"><xsl:value-of select="Title"/></td>
                    </tr>
                    <tr>
                      <td class="AbstractCell"><xsl:value-of select="Abstract"/></td>
                    </tr>
                    <tr>
                      <td class="UrlCell">
                        <xsl:element name="a">
                          <xsl:attribute name="href"><xsl:value-of select="Url"/></xsl:attribute>
                          <xsl:attribute name="target">_blank</xsl:attribute>
                          <xsl:value-of select="Url"/>
                        </xsl:element>
                      </td>
                    </tr>
                  </xsl:for-each>
                </table>
              </td>
              </xsl:element>
          </xsl:for-each>
        </table>
      </body>
    </html>
  </xsl:template>
</xsl:stylesheet>
